package com.macro.mall.search.config;

import com.macro.mall.common.config.BaseSwaggerConfig;
import com.macro.mall.common.domain.SwaggerProperties;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger API文档相关配置
 * 2.7 以后
 * 需要springboot的配置增加增加一下配置
 * spring
 *   mvc:
 *     path-match:
 *       matching-strategy: ant_path_matcher
 */
@Configuration
@EnableSwagger2 // 需要开启
public class SwaggerConfig extends BaseSwaggerConfig {

    @Override
    public SwaggerProperties swaggerProperties() {
        return SwaggerProperties.builder()
                .apiBasePackage("com.macro.mall.search.controller")
                .title("mall搜索系统")
                .description("mall搜索相关接口文档")
                .contactName("macro")
                .version("1.0")
                .enableSecurity(false)
                .build();
    }


    // 解决 https://blog.csdn.net/zxl_leo/article/details/131471689
    // Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
    @Bean
    public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
        // 解决方案如下
        return generateBeanPostProcessor();
    }
}
